package com.yjd.bi.statistic.control;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.yjd.bi.user.service.IInvestRateDaysService;
import com.yjd.bi.user.service.IInvestRateMonthService;
import com.yjd.bi.user.service.IInvestRateWeekService;
import com.yjd.bi.user.service.ILoginRateDaysService;
import com.yjd.bi.user.service.ILoginRateMonthService;
import com.yjd.bi.user.service.ILoginRateWeekService;
import com.yjd.bi.user.service.ILoginRetentionRateService;
import com.yjd.comm.annotation.ServiceRemoteProxy;
import com.yjd.comm.base.control.BaseControl;
import com.yjd.comm.rpm.RpmServiceKeyEnum;

@Controller
@Scope("prototype")
@RequestMapping("userKeep")
public class UserKeepRateControl extends BaseControl {
	
	/**
	 * 登录留存率
	 * 
	 * @return
	 * @throws Exception
	 *             String
	 */
	@RequestMapping("loginRateBysex")
	public String loginRateBysex(@RequestParam Integer skip,@RequestParam Long sex) throws Exception {
		if (7 == skip) {
			request.setAttribute("resultMaps",
					loginRateDaysService.getLoginDaysRate(skip,sex));
			return "userStatistic/login_rate_7days";
		}
		if (30 == skip) {
			request.setAttribute("resultMaps",
					loginRateDaysService.getLoginDaysRate(skip,sex));
			return "userStatistic/login_rate_30days";
		}
		if (13 == skip) {
			request.setAttribute("resultMaps",
					loginRateWeekService.getLoginWeekRate(skip,sex));
			return "userStatistic/login_rate_13week";
		}

		request.setAttribute("resultMaps",
				loginRateMonthService.getLoginMonthRate(skip,sex));
		return "userStatistic/login_rate_12month";

	}
	
	
	/**
	 * 投资留存率
	* @param skip
	* @return
	* @throws Exception
	* String
	 */
	@RequestMapping("investRateBySex")
	public String investRateBySex(@RequestParam Integer skip,@RequestParam Long sex) throws Exception {
		if (7 == skip) {
			request.setAttribute("resultMaps",
					investRateDaysService.getInvestDaysRate(skip,sex));
			return "userStatistic/invest_rate_7days";
		}
		if (30 == skip) {
			request.setAttribute("resultMaps",
					investRateDaysService.getInvestDaysRate(skip,sex));
			return "userStatistic/invest_rate_30days";
		}
		if (13 == skip) {
			request.setAttribute("resultMaps",
					investRateWeekService.getInvestWeekRate(skip,sex));
			return "userStatistic/invest_rate_13week";
		}

		request.setAttribute("resultMaps",
				investRateMonthService.getInvestMonthRate(skip,sex));
		return "userStatistic/invest_rate_12month";

	}
	
	
	/**
	 * 登录留存率(地区)
	 * 
	 * @return
	 * @throws Exception
	 *             String
	 */
	@RequestMapping("loginRateByArea")
	public String loginRateByArea(@RequestParam Integer skip,@RequestParam Long area) throws Exception {
		if (7 == skip) {
			request.setAttribute("resultMaps",
					loginRateDaysService.getLoginDaysRate(skip,area));
			return "userStatistic/login_rate_7days";
		}
		if (30 == skip) {
			request.setAttribute("resultMaps",
					loginRateDaysService.getLoginDaysRate(skip,area));
			return "userStatistic/login_rate_30days";
		}
		if (13 == skip) {
			request.setAttribute("resultMaps",
					loginRateWeekService.getLoginWeekRate(skip,area));
			return "userStatistic/login_rate_13week";
		}

		request.setAttribute("resultMaps",
				loginRateMonthService.getLoginMonthRate(skip,area));
		return "userStatistic/login_rate_12month";

	}
	
	/**
	 * 投资留存率 (地区)
	* @param skip
	* @return
	* @throws Exception
	* String
	 */
	@RequestMapping("investRateByArea")
	public String investRateByArea(@RequestParam Integer skip,@RequestParam Long area) throws Exception {
		if (7 == skip) {
			request.setAttribute("resultMaps",
					investRateDaysService.getInvestDaysRate(skip,area));
			return "userStatistic/invest_rate_7days";
		}
		if (30 == skip) {
			request.setAttribute("resultMaps",
					investRateDaysService.getInvestDaysRate(skip,area));
			return "userStatistic/invest_rate_30days";
		}
		if (13 == skip) {
			request.setAttribute("resultMaps",
					investRateWeekService.getInvestWeekRate(skip,area));
			return "userStatistic/invest_rate_13week";
		}

		request.setAttribute("resultMaps",
				investRateMonthService.getInvestMonthRate(skip,area));
		return "userStatistic/invest_rate_12month";

	}

	@ServiceRemoteProxy(serviceUrlResouceKey = RpmServiceKeyEnum.RPM_BI_SERVICE_KEY)
	private ILoginRetentionRateService loginRetentionRateService;

	@ServiceRemoteProxy(serviceUrlResouceKey = RpmServiceKeyEnum.RPM_BI_SERVICE_KEY)
	private ILoginRateDaysService loginRateDaysService;

	@ServiceRemoteProxy(serviceUrlResouceKey = RpmServiceKeyEnum.RPM_BI_SERVICE_KEY)
	private ILoginRateWeekService loginRateWeekService;

	@ServiceRemoteProxy(serviceUrlResouceKey = RpmServiceKeyEnum.RPM_BI_SERVICE_KEY)
	private ILoginRateMonthService loginRateMonthService;
	
	@ServiceRemoteProxy(serviceUrlResouceKey = RpmServiceKeyEnum.RPM_BI_SERVICE_KEY)
	private IInvestRateDaysService investRateDaysService;
	
	@ServiceRemoteProxy(serviceUrlResouceKey = RpmServiceKeyEnum.RPM_BI_SERVICE_KEY)
	private IInvestRateWeekService investRateWeekService;
	
	@ServiceRemoteProxy(serviceUrlResouceKey = RpmServiceKeyEnum.RPM_BI_SERVICE_KEY)
	private IInvestRateMonthService investRateMonthService;

}
